const birdDom = document.getElementsByClassName('bird')[0];
const birdStyle = getComputedStyle(birdDom);
const birdWidth = parseFloat(birdStyle.width);
const birdHieght = parseFloat(birdStyle.height);
const birdLeft = parseFloat(birdStyle.left);
const birdTop = parseFloat(birdStyle.top);
class Bird extends JuXing {
    constructor() {
        super(birdWidth, birdHieght, birdLeft, birdTop, 0, 0, birdDom);
        this.g = 1500;
        this.index = 1; //小鸟翅膀索引
        this.maxTop = skyHeight - landHeight - birdHieght;
        this.timer = null;
    }

    move(shijian) {
        super.move(shijian);
        this.ySpeed = this.g * shijian + this.ySpeed;
    }

    onMove() {
        if (this.top <= 0) {
            this.top = 0;
        } else if (this.top > this.maxTop) {
            this.top = this.maxTop;
        }
    }

    jump() {
        this.ySpeed = -450;
    }

    start() {
        if(this.timer){
            return;
        }
        this.timer = setInterval(() => {
            this.index++;
            if(this.index === 4){
                this.index = 1;
            }
            super.rander();
            this.dom.className = `bird bird${this.index}`;
        }, 200);
    }

    stop() {
        clearInterval(this.timer);
        this.timer = null;
    }
}

// var bird = new Bird();

// setInterval(() => {
//     bird.move(16 / 1000);
// }, 16);